package BoardGameToTreeIntegration;

import java.io.File;
import java.io.IOException;

import org.eclipse.emf.ecore.EObject;
import org.moflon.moca.txt.unparser.TxtUnparserAdapter;
import org.moflon.util.TranslatorHelper;
import org.moflon.util.eMoflonEMFUtil;

import BoardGame.BoardGamePackage;
import Moca.CodeAdapter;
import Moca.MocaFactory;
import MocaTree.MocaTreePackage;
import TGGLanguage.TGGLanguagePackage;
import TGGLanguage.algorithm.ApplicationTypes;
public class TGGMainForw {
	public static void main(String[] args) throws IOException {
		TranslatorHelper helper = new TranslatorHelper();

		helper.setOutputModel(MocaTreePackage.eINSTANCE,
				"./instances/tree/Board1x1empty.xmi");
		helper.setInputModel(BoardGamePackage.eINSTANCE,
				"./instances/model/Board1x1empty.xmi");
		helper.setCorrModel(BoardGameToTreeIntegrationPackage.eINSTANCE,
				"./instances/CorrespondenceModel.xmi");
		helper.setDirection(ApplicationTypes.FORWARD);
		helper.setStaticAnalysis("../BoardGameToTreeIntegration/"
				+ "model/BoardGameToTreeIntegration.gen.sma.xmi");
		try {
			helper.integrate();
		} catch (Exception e) {
			e.printStackTrace();
			
		}
		EObject created = helper.getOutputRoot();
		
		eMoflonEMFUtil.saveModel(TGGLanguagePackage.eINSTANCE, helper.getTranslationProtocol(), "./instances/protocol.xmi");
		
		System.out.println(created);
		
		
//		CodeAdapter codeAdapter = MocaFactory.eINSTANCE.createCodeAdapter();
//	    codeAdapter.getUnparser().add(new TxtUnparserAdapter());
//
//		MocaTree.File file; 
//		EObject rootObj = eMoflonEMFUtil.loadModel(MocaTreePackage.eINSTANCE, "../BoardGameToTreeIntegration/instances/tree/tree.xmi", null);
//		if (rootObj instanceof MocaTree.Folder)
//		{
//			codeAdapter.unparseFile(((MocaTree.Folder) rootObj).getFile().get(0), new File("instances/text"));
//		}else if (rootObj instanceof MocaTree.File) {
//			codeAdapter.unparseFile((MocaTree.File) rootObj, new File("instances/text")); 			
//		}
	    
	}
}